# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :login_utils.py
# @Time      :2022/6/9 0009 14:34
# @Author    :何胜利
from functools import wraps

from flask import g


def login_required(func):
    @wraps(func)
    def wrapper(*args, **kwargs):

        if g.user_id:
            return func(*args, **kwargs)
        else:
            return {"message": "请先登录"}, 401

    return wrapper
